<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主</title>
<import type='css' file="css.main" />
<load href="__PUBLIC__/js/jquery-1.9.1.min.js" />
<import type='js' file="js.main" />
	<style type="text/css">
		body{font-size: 14px;}
		h1.infotitle{display: block; text-align: center; line-height: 36px; clear: both; overflow: hidden; margin-top: 60px; font-weight: normal; font-size: 32px;}
		.awardw{width: 80%; margin: 0px auto;}
		.tableinfo{width: 100%; clear: both; margin-top: 20px;}
		table{border-collapse:collapse; border: solid 1px #ebebeb; border-color: #ebebeb;}
		table th{height: 40px; line-height: 40px; background-color: #666; color: #fff; font-weight: normal; font-size: 16px;}
		table tr td{text-align: center; padding: 10px;}
		.awardresult{line-height: 32px; clear: both; margin-top: 20px; font-size: 16px; text-align: center;}
		.awardresult select{height: 25px; line-height: 25px; border-radius: 5px;}
		.awardresult select option{line-height: 25px;}
		.caozuo a{text-align: center; color: #fff; cursor: pointer; padding: 4px 12px; border-radius:5px;}
		.caozuo a.delete{background-color: #ff5454;}
		.caozuo a.edit{background-color: #ffad54;}
		.caozuo a:hover{background-color: #383e4c;}
		.page{text-align: center;}
		.page a{color: #333;}
		.page *{display: inline; padding: 0px 3px;}
		.tdselect select{border: none; height: 24px; line-height: 24px; width: 80%;}
		.btnprodu{clear: both; overflow: hidden; margin: 20px 0px; margin-bottom: 3px; text-align: center;}
		.btnprodu input{display: inline; border: none; cursor: pointer; height: 32px; font-size: 16px; padding: 5px 20px; font-weight: bold; color: #fff; background-color: #ff5454; border-radius: 5px; margin: 0px 10px;}
		.btnprodu input.bj0{background-color: #32d088;}
		.btnprodu input.bj1{background-color: #32cee4;}
		.btnprodu input.bj2{background-color: #fb6e51;}
		.btnprodu input.bj3{background-color: #f5b252;}
		.btnprodu input.gray{background-color: #ccc;}
		.btnprodus{margin-top: 0px; clear: both; overflow: hidden; height: 30px; width: 821px; margin: 0px auto;}
		.btnprodus span{display: block; float:left; padding: 5px 20px; margin: 0px 32px; color: #666; display: none;}
		.asid{clear: both; overflow: hidden; border-bottom: solid 1px #ccc;}
		.msg{clear: both; overflow: hidden; text-align: center; color: #f00; margin-top: 16px; line-height: 38px; font-size: 16px;}
	</style>
</head>

<body>
<div class="asid">
	<div class="btnprodu btnarray">
		<volist name="timelist" id="time">
			<input type="button" class="btn" v="{$time['awardid']}" value="{$time['awardtime']}" />
		</volist>
	</div>
	<div class="btnprodu btnprodus">
		<span>已产生中奖名单</span>
		<span>已产生中奖名单</span>
		<span>已产生中奖名单</span>
		<span>已产生中奖名单</span>
	</div>
	<div class="msg">* 注意：在距每一轮的开奖时间前几分钟进行操作</div>
</div>


<div class="awardw">
	<h1 class="infotitle">中奖信息</h1>
	<div class="awardresult">
		<label>中奖结果:</label>
		<select name="awareresult" onchange="goUrl(this.options[this.selectedIndex]);">
			<option value="{:U('awardedinfo')}">请选择</option>
			<volist name="awardlist" id="v">
			<option value="{:U('awardedinfo',array('awardid'=>$v['id']))}" <if condition="$v['id'] eq $awardid">selected</if>>{$v['awardname']}</option>
			</volist>
		</select>
		<label>中奖数量：<b>{$count}</b></label>
	</div>
	<div class="tableinfo">
		<table width="100%" border="1" cellspacing="0" cellpadding="0" class="indextable">
			<tr>
				<th width="5%">ID</th>
				<th width="15%">姓名</th>
				<th width="15%">手机号</th>
				<th width="30%">奖品名称</th>
				<th width="10%">领取状态</th>
				<th width="25%">操作</th>
			</tr>
			<volist name="result" id="v" empty="没有中奖数据">
			<tr>
				<td>{$v['id']}</td>
				<td>{$v['name']}</td>
				<td>{$v['mobile']}</td>
				<td class="tdselect">
					<select name="awareresult1">
						<volist name="awardlist" id="v1">
							<option value="{$v1['id']}" <if condition="$v1['id'] eq $v['awardid']">selected</if>>{$v1['awardname']}</option>
						</volist>
					</select>
				</td>
				<td class="astatus">{:W('Jgward/awardstatus',array('id'=>$v['id']))}</td>
				<td class="caozuo">-
					<!--<a class="delete" v="{$v['id']}">删除</a> &nbsp;&nbsp; <a class="edit" v="{$v['id']}">修改</a>-->
				</td>
			</tr>
			</volist>
		</table>
		<div class="page">{$page}</div>
	</div>
</div>
<script type="text/javascript">
	function goUrl(obj){
		location.href=obj.value;
	}
	$(function(){
		var anum = '{$awardnum}';
		$(".btnprodus span:lt("+anum+")").show();
		$(".btnarray input:lt("+anum+")").attr('disabled','disabled').addClass('gray');

		//产生中奖名单
		$(".btnarray input").each(function(index,element){
			var t = $(this);
			t.click(function(){
				var awardid = $(this).attr('v');
				var url = "{:U('akj')}";
				var setdata = {"awardid":awardid,random:Math.random()};
				$.ajax({
					url:url,
					data:setdata,
					type:"POST",
					dataType:"JSON",
					success:function (data){
						//alert(data.ret);
						location.reload();
					}
				});
			})
		})

		//改变按钮背景色
		$(".btnprodu input").each(function(index,element){
			$(this).addClass("bj"+index);
		})

		$(".tableinfo table tr").each(function(index,element){
			var t = $(this);
			t.find("a.edit").click(function(){
				var id = $(this).attr('v');
				var awardid = t.find("select").val();
				sendedit(id,awardid);
			})
		})
		function sendedit(id,awardid){
			var url = "{:U('awardedit')}";
			var setdata = {"id":id,"awardid":awardid,random:Math.random()};
			$.ajax({
				url:url,
				data:setdata,
				type:"POST",
				dataType:"JSON",
				success:function (data){
					if(data.ret!=1){
						alert('修改失败，请重新操作');
						location.reload();
					}else{
						location.reload();
					}
				}
			});
		}

		$(".astatus").each(function(index,element){
			if($(this).html()=='已领取'){
				$(".caozuo:eq("+index+") *").removeAttr('class');
				$(".caozuo:eq("+index+")").html(null);
			}
		})
		//删除
		$("a.delete").each(function(index,element){
			var t = $(this);
			t.click(function(){
				var r=confirm("想好！确定要删除吗？");
				if (r==true){
					var id = $(this).attr('v');
					var savetel_url = "{:U('delete')}";
					var teldata = {"id":id,random:Math.random()};
					$.ajax({
						url:savetel_url,
						data:teldata,
						type:"POST",
						dataType:"JSON",
						success:function (data){
							if(data.ret==1){
								location.reload();
							}else{
								alert('删除失败，请重新操作');
								location.reload();
							}
						}
					});
				}else{
					return false;
				}

			})
		})

	})
</script>
</body>
</html>
